package com.zzyl.mapper;

import com.zzyl.dto.BedDto;
import com.zzyl.entity.Bed;
import com.zzyl.vo.BedVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BedMapper {

    List<BedVo> getBedsByRoomId(Long roomId);

    //新增床位
    void insertBed(Bed bed);
    //新增床位->判断床位号码重复
    @Select("select * from zzyl.bed where bed_number=#{bedNumber}")
    Bed getBedNumber(String bedNumber);


    //根据ID查询床位 回显
    BedVo selectById(Long id);

    //更新床位
    void updateById(Bed bed);
    //更新床位->判断床位号码重复和自己号码重复
    @Select("select count(1) from zzyl.bed where bed_number=#{bedNumber} and id != #{id}")
    Long getNumber(@Param("bedNumber") String bedNumber,@Param("id") Long id);


    //5.3.4 删除床位
    void deleteById(Long id);

}

